#! /bin/sh
#### Run GBmod with CWP PostScript Graphics
#### Create Figure 7 in the GBmod paper

if test "$PSPREVIEWER" = ""
then
echo "Environment variable PSPREVIEWER not set" ; exit 1
fi

# model number
model=4

####  find the right directory
datadir=../datadir/

####  aux files
modelfile=${datadir}model${model}.data
modelpsfile=${datadir}model${model}.eps
rayendsfile=${datadir}rayend.data
rayfile=${datadir}ray.data
raypsfile=${datadir}ray.eps

nangle=150 fangle=-45 langle=45 nxz=201 
nplotr=$nangle nt=20 target=5

####   generate modelfile and modelpsfile
#../Models/PSmodel${model}

####   shoot the rays 
triray <$modelfile >$rayendsfile \
        rayfile=$rayfile nangle=$nangle \
        nxz=$nxz xs=5 zs=1.2 \
        fangle=$fangle langle=$langle \
        refseq=$target,1 refseq=2,-1 krecord=2 \

####   plot the rays 
psgraph <$rayfile >$raypsfile \
        nplot=`cat outpar` n=$nxz hbox=3.0 wbox=6  \
        x1beg=0 x1end=10 x2beg=0 x2end=20 \
        label1="Depth (km)" label2="Distance (km)" \
        style=seismic linegray=1

spsplot <$modelfile gtri=-1\
        label1="Depth (km)" label2="Distance (km)" \
        hbox=3.0 wbox=6 \
        >$modelpsfile

####    display  rays and model
$CWPROOT/bin/psmerge in=$modelpsfile in=$raypsfile |
        $PSPREVIEWER  &


exit 0

